﻿/***********************************************************************************************
 * 
 * ProjectName: WMSSoft.Lib.Basic
 * 
 * Description: Class Describes a single Module - Setting
 * 
 * Created:     10.05.2015
 * 
 * Author:      matthias wagler - matthias@WMSSoft.de
 * 
 * Copyright:   Copyright 2012 by WMSSoft.net
 * 
 * License:     GPLv3
 * 
 * History:     10.05.2015 - matthias wagler matthias@WMSSoft.de   -   Created
 * 
 **********************************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WMSSoft.Lib.Enums;

namespace WMSSoft.Lib.Basic
{
    /// <summary>
    /// Describe a Setting Option
    /// (Data-Type, Available Values, Min - Max - Value if Numeric
    /// and Min - Max - Length if a Textvalue
    /// </summary>
    public class OptionInfo
    {
        #region Members
        OptionValueType m_OptionValueType = OptionValueType.otNotSet;
        int m_iMinValueLength = 0;
        int m_iMaxValueLength = 0;
        int m_iMinNumericValue = 0;
        int m_iMaxNumericValue = 0;
        double m_dMinNumericDoubleValue = 0.0;
        double m_dMaxNumericDoubleValue = 0.0;
        List<KeyValueAssignment> m_oAvailableValues = new List<KeyValueAssignment>();
        string m_DefaultValue = "";
        string m_ValueCaption = "";
        #endregion

        #region Constructors

        /// <summary>
        /// Initialize a new OptionInfo for Value-type = otBoolean
        /// </summary>
        /// <param name="Caption">Set the Usercaption for this Value</param>
        public OptionInfo(string Caption)
        {
            m_DefaultValue = "False";
            m_ValueCaption = Caption;
            m_OptionValueType = OptionValueType.otBoolean;
        }

        /// <summary>
        /// Initialize a new OptionInfo for Value-type = otText
        /// </summary>
        /// <param name="MaxLength">Maximum Length for the Textvalue</param>
        /// <param name="Caption">Set the Usercaption for this Value</param>
        public OptionInfo(int MaxLength, string Caption)
        {
            m_DefaultValue = "2";
            m_ValueCaption = Caption;
            m_OptionValueType = OptionValueType.otText;
            m_iMaxValueLength = MaxLength;
        }

        /// <summary>
        /// Initialize a new OptionInfor for Value-type = otList
        /// </summary>
        /// <param name="AvailableValues">Available Values for this Option</param>
        /// <param name="Caption">Set the Usercaption for this Value</param>
        public OptionInfo(List<KeyValueAssignment> AvailableValues, string Default, string Caption)
        {
            m_DefaultValue = Default;
            m_ValueCaption = Caption;
            m_OptionValueType = OptionValueType.otList;
            m_oAvailableValues = AvailableValues;
        }

        /// <summary>
        /// Initialize a new OptionInfor for Value-type = otNumeric
        /// </summary>
        /// <param name="MinValue">Minimum Value</param>
        /// <param name="MaxValue">Maximum Value</param>
        /// <param name="Caption">Set the Usercaption for this Value</param>
        public OptionInfo(int MinValue, int MaxValue, string Caption)
        {
            m_DefaultValue = "0";
            m_ValueCaption = Caption;
            m_OptionValueType = OptionValueType.otNumeric;
            m_iMinNumericValue = MinValue;
            m_iMaxNumericValue = MaxValue;
        }

        /// <summary>
        /// Initialize a new OptionInfor for Value-type = otNumericDouble
        /// </summary>
        /// <param name="MinValue">Minimum Value</param>
        /// <param name="MaxValue">Maximum Value</param>
        /// <param name="Caption">Set the Usercaption for this Value</param>
        public OptionInfo(double MinValue, double MaxValue, string Caption)
        {
            m_DefaultValue = "0.0";
            m_ValueCaption = Caption;
            m_OptionValueType = OptionValueType.otNumericDouble;
            m_dMinNumericDoubleValue = MinValue;
            m_dMaxNumericDoubleValue = MaxValue;
        }
        #endregion

        #region Properties
        /// <summary>
        /// Give or set the Option - DataType
        /// </summary>
        public OptionValueType Type
        {
            get { return m_OptionValueType; }
            set { m_OptionValueType = value; }
        }

        /// <summary>
        /// Get or set the minimum Text length for this Option Value if DataType is ofText
        /// </summary>
        public int MinLengthValue
        {
            get { return m_iMinValueLength; }
            set { m_iMinValueLength = value; }
        }

        /// <summary>
        /// Get or set the maximum Text length for this Option Value if DataType is ofText
        /// </summary>
        public int MaxLengthValue
        {
            get { return m_iMaxValueLength; }
            set { m_iMaxValueLength = value; }
        }

        /// <summary>
        /// Get or set the minimum Value for this Option Value if DataType is ofNumeric
        /// </summary>
        public int MinNumValue
        {
            get { return m_iMinNumericValue; }
            set { m_iMinNumericValue = value; }
        }

        /// <summary>
        /// Get or set the maximum Value for this Option Value if DataType is ofNumeric
        /// </summary>
        public int MaxNumValue
        {
            get { return m_iMaxNumericValue; }
            set { m_iMaxNumericValue = value; }
        }

        /// <summary>
        /// Get or set the minimum Value for this Option Value if DataType is ofNumericDouble
        /// </summary>
        public double MinNumDblValue
        {
            get { return m_dMinNumericDoubleValue; }
            set { m_dMinNumericDoubleValue = value; }
        }

        public double MaxNumDblValue
        {
            get { return m_dMaxNumericDoubleValue; }
            set { m_dMaxNumericDoubleValue = value; }
        }

        /// <summary>
        /// List all usable values if DataType ist otList
        /// </summary>
        public List<KeyValueAssignment> AvailableValues
        {
            get { return m_oAvailableValues; }
            set { m_oAvailableValues = value; }
        }

        /// <summary>
        /// Get or set the Default Value for this Option
        /// </summary>
        public string Default
        {
            get { return m_DefaultValue; }
            set { m_DefaultValue = value; }
        }

        /// <summary>
        /// Get or set the Caption for this Value Key
        /// </summary>
        public string Caption
        {
            get { return m_ValueCaption; }
            set { m_ValueCaption = value; }
        }
        #endregion
    }
}
